﻿/// <reference path="../ext-3.3.1/adapter/ext/ext-base.js" />
/// <reference path="../ext-3.3.1/ext-all.js" />

Ext.namespace("CommonWebApp");

CommonWebApp._MainView = {
    CreateTreeNode: function (id, text, leaf) {
        return new Ext.tree.TreeNode({
            id: id,
            text: text,
            leaf: leaf
        });
    },
    CreateSystemTreeMenu: function () {
        var tree = new Ext.tree.TreePanel({
            title: '系统功能',
            rootVisible: false,
            border: true
        });

        var root = new Ext.tree.TreeNode({
            text: 'root',
            expanded: true,
            id: 'root'
        });
        tree.setRootNode(root);
        root.appendChild(this.CreateTreeNode('usermanagepanel', '用户管理', true));
        root.appendChild(this.CreateTreeNode('departmentmanagepanel', '部门管理', true));
        root.appendChild(this.CreateTreeNode('rolermanagepanel', '权限管理', true));

        return tree;
    },
    CreateHomePage: function () {
        var homePage = {
            id: 'homepage',
            title: '首页',
            layout: 'fit',
            bodyStyle: 'padding:25px',
            cls: 'homepage'
        };
        return homePage;
    },
    CreateMainTabPanel: function () {
        var tabPanel = new Ext.TabPanel({
            id: 'mainTabPanel',
            region: 'center',
            enableTabScroll: true,
            deferredRender: false,
            margin: '0 5 5 0',
            activeTab: 0,
            iconCls: 'tabs',
            items: [this.CreateHomePage()]
        });
        return tabPanel;
    },
    CreateUserPanel: function () {

    },
    MainViewPage: function () {
        new Ext.Viewport({
            layout: 'border',
            items: [{
                xtype: 'box',
                region: 'north',
                applyTo: 'header',
                height: 38
            }, {
                xtype: 'box',
                region: 'south',
                applyTo: 'footer',
                height: 38
            }, {
                region: 'west',
                id: 'west-panel',
                title: '功能菜单',
                split: true,
                width: 200,
                minSize: 175,
                maxSize: 400,
                collapsible: true,
                margins: '0 0 0 5',
                cmargins: '0 5 5 5',
                layout: 'accordion',
                layoutConfig: {
                    animate: true
                },
                border: false,
                items: [this.CreateSystemTreeMenu()]
            },
        this.CreateMainTabPanel()]
        });
    }
}